package com.sendi.system.bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;

import javax.sql.DataSource;

import com.sendi.system.entity.Syslogs;
import com.sendi.system.service.ServiceSupportImp;

/*
 * 系统日志记录类
 */
public class SysLogHelper {
    public DataSource dataSource;
	public void Log(String username,String loginhost,String resutl,String operatetime,String logcontent,String operatename)
	{
	 	try
	 	{
		 Connection con=dataSource.getConnection();
		 if(con!=null)
		 {
			  String sql="insert into syslogs (logname,loguser,logterminal,logresult,logcontent,logtime) values(?,?,?,?,?,?)";
			  PreparedStatement pst=con.prepareStatement(sql);
			  pst.setString(1, operatename);
			  pst.setString(2, username);
			  pst.setString(3, loginhost);
			  pst.setString(4, resutl);
			  pst.setString(5, logcontent);
			  pst.setString(6, operatetime);
			  pst.executeUpdate();
		 }
	 	 
		}catch (Exception e) {
		 e.printStackTrace();
		}
		
	}
	
	public void LogJobhistory(String jobdesc, String jobstartTime,
			String jboendTime, String jobName, String jobGroupname)
	{
	 	try
	 	{
		 Connection con=dataSource.getConnection();
		 if(con!=null)
		 {
			  String sql="insert into sys_job_interface_log  (jobdesc,jobstart_time,jobend_time,job_name,job_groupname) values(?,?,?,?,?)";
			  PreparedStatement pst=con.prepareStatement(sql);
			  pst.setString(1, jobdesc);
			  pst.setString(2, jobstartTime);
			  pst.setString(3, jboendTime);
			  pst.setString(4, jobName);
			  pst.setString(5, jobGroupname);
		 	  pst.executeUpdate();
		 }
	 	 
		}catch (Exception e) {
		 e.printStackTrace();
		}
		
	}
	
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
 

}
